package com.framework.buss.ai.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.framework.buss.ai.mapper.QuestionHisMapper;
import com.framework.buss.ai.model.QuestionHis;
import com.framework.buss.ai.params.QuestionHisParam;
import com.framework.buss.ai.service.IQuestionHisService;
import com.framework.common.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zzg
 */
@Service
public class QuestionHisService implements IQuestionHisService {
    @Autowired
    private QuestionHisMapper questionHisMapper;

    @Override
    public IPage<QuestionHis> list(QuestionHisParam param, Page page) {
        // 查询数据
        IPage<QuestionHis> list = questionHisMapper.selectList(page, param);
        return list;
    }

    @Override
    public String save(QuestionHis param) {
        String id = param.getId();
        if (StringUtils.isBlank(id)) {
            questionHisMapper.insert(param);
        } else {
            questionHisMapper.updateById(param);
        }

        return param.getId();
    }

    @Override
    public void del(List<String> id) {
        questionHisMapper.deleteBatchIds(id);
    }

    @Override
    public QuestionHis getOne(String id) {
        return questionHisMapper.selectById(id);
    }
}
